<?php

namespace haibao\cms\data\starpk;

use \haibao\cms\model\filter\starpk\StarPkCelebrity as StarPkCelebrityFilter;

class StarPkCelebrity extends \haibao\cms\data\BaseMysql{

    public function __construct(){
        parent::__construct('\haibao\cms\model\data\starpk\StarPkCelebrity');
    }
    
    public function getStarPkCelebrityById($celebrityId){
        $starPkCelebrityFilter = new StarPkCelebrityFilter();
        $starPkCelebrityFilter->select(array(
            StarPkCelebrityFilter::CONDITION_FIELD_NAME_ID,
            StarPkCelebrityFilter::CONDITION_FIELD_NAME_STAR_PK_ID,
            StarPkCelebrityFilter::CONDITION_FIELD_NAME_CELEBRITY_ID ,
            StarPkCelebrityFilter::CONDITION_FIELD_NAME_PIC_URL,
            StarPkCelebrityFilter::CONDITION_FIELD_NAME_PIC_SOURCE,
            StarPkCelebrityFilter::CONDITION_FIELD_NAME_CELEBRITY_DESC,
            StarPkCelebrityFilter::CONDITION_FIELD_NAME_SORT_NUM,
            StarPkCelebrityFilter::CONDITION_FIELD_NAME_CELEBRITY_VOTE_NUM,
            StarPkCelebrityFilter::CONDITION_FIELD_NAME_CREATE_TIME,
        ));
        $starPkCelebrityFilter->where(StarPkCelebrityFilter::CONDITION_FIELD_NAME_STAR_PK_ID,\haibao\frame\data\query\Condition::CONDITION_EQUAL,(int)$celebrityId);
        return $this->getAll($starPkCelebrityFilter);
    }
    
    public function updateStarPkCelebrityVoteNum($starPkId,$celebrityId){
    	$sql = 'update StarPkCelebrity set CelebrityVoteNum=CelebrityVoteNum+1 where StarPkId=%s and CelebrityId=%s';
    	$this->query($sql,array($starPkId,$celebrityId));

    	$sql = 'update StarPkProperty set StarVoteNum=StarVoteNum+1 where StarPkId=%s';
    	$this->query($sql,array($starPkId));
    }
    
    
}